import request from "@/api/request.js";

//请求前缀
const PREFIX = "/user";

export function findUserList(pageNo, pageSize, param) {
  return request({
    //模板字符串拼接参数
    url: `${PREFIX}/list/${pageNo}/${pageSize}`,
    method: "GET",
    params: param,
  });
}

export function login(data) {
  return request({
    //模板字符串拼接参数
    url: `${PREFIX}/login`,
    method: "POST",
    data: data,
  });
}

export function doEmailLogin(data) {
  return request({
    //模板字符串拼接参数
    url: `${PREFIX}/login/email`,
    method: "POST",
    data: data,
  });
}

export function register(data) {
  return request({
    //模板字符串拼接参数
    url: `${PREFIX}/register`,
    method: "POST",
    data: data,
  });
}

export function doLogout(token) {
  return request({
    //模板字符串拼接参数
    url: `${PREFIX}/logout`,
    method: "POST"
  });
}


export function getUserInfo() {
  return request({
    //模板字符串拼接参数
    url: `${PREFIX}/info`,
    method: "POST"
  });
}

export function queryRoles(userId) {
  return request({
    //模板字符串拼接参数
    url: `${PREFIX}/roles/${userId}`,
    method: "GET",
  });
}

export function queryEchoUserInfo(id) {
  return request({
    //模板字符串拼接参数
    url: `${PREFIX}/echo/${id}`,
    method: "GET",
  });
}

export function updateUserStatus(id) {
  return request({
    //模板字符串拼接参数
    url: `${PREFIX}/update/status/${id}`,
    method: "PUT",
  });
}

export function updateUserInfo(data) {
  return request({
    //模板字符串拼接参数
    url: `${PREFIX}/update`,
    method: "PUT",
    data: data
  });
}

export function saveRoles(username, data) {
  return request({
    //模板字符串拼接参数
    url: `${PREFIX}/save/roles/${username}`,
    method: "POST",
    data: data,
  });
}

export function deleteUser(id) {
  return request({
    //模板字符串拼接参数
    url: `${PREFIX}/delete/${id}`,
    method: "DELETE",
  });
}

export function resetPwd(data) {
  return request({
    //模板字符串拼接参数
    url: `${PREFIX}/reset/pwd`,
    method: "POST",
    data: data
  });
}

export function sendMs(email) {
  return request({
    //模板字符串拼接参数
    url: `${PREFIX}/send/code`,
    method: "GET",
    params: {
      email
    }
  });
}